package com.cswnode.Util;

/**
 * @author csw
 * @create 2020/10/2 19:27
 */

public class RedisKeyUtil {
    /**
     * 连接
     */
    private static final String ATTACH = ":";
    /**
     * 点赞实体
     */
    private static final String ENTITY_LIKE = "like:entity";
    /**
     * 用户点赞
     */
    private static final String USER_LIKE = "like:user";

    /**
     * 被关注者
     */
    private static final String FOLLOWERS = "followers";
    /**
     * 粉丝
     */
    private static final String FANS = "fans";
    /**
     * 用户
     */
    private static final String User = "user";
    /**
     * 验证码
     */
    private static final String KAPTCHA = "kaptcha";
    /**
     * 登陆凭证
     */
    private static final String TICKET = "ticket";

    public static String getRedisEntityKey(int EntityType,int EntityId){
        return ENTITY_LIKE + ATTACH + EntityType + ATTACH + EntityId;
    }

    public static String getRedisUserKey(int userId){
        return USER_LIKE + ATTACH + userId;
    }

    //被关注者的key(偶像)
    //followers:entityId:entityType
    //存储的值为粉丝的id
    //value(userId,data)
    public static String getFollowersKey(int entityId,int entityType){
        return FOLLOWERS + ATTACH + entityId + ATTACH + entityType;
    }

    //粉丝的key(粉丝)
    //fans:userId:entityType
    //存储的值为关注者的id
    //value(entityId，data)
    public static String getFonsKey(int userId,int entityType){
        return FANS + ATTACH + userId + ATTACH + entityType;
    }

    /**
     * 登陆验证码
     */
    public static String getKaptcha(String owner){
        return KAPTCHA + ATTACH + owner;
    }

    /**
     * 登陆凭证
     * @param ticket
     * @return
     */
    public static String getTicket(String ticket){
        return TICKET + ATTACH + ticket;
    }
    public static String getUserKey(int userId){
        return User + ATTACH + userId;
    }



}
